package jy_log

import (
	"fmt"
	Config "jy_go/config"
	"log"
	"os"
	"time"
)

var (
	ErrLog = Config.Config("config","log","err_log")
)

//写入日志
func JyLog(Content string) {
	//创建目录
	_ = os.Mkdir(ErrLog, os.ModePerm)
	_ = os.Mkdir("./"+ErrLog+"/" + time.Now().Format("2006-01"), os.ModePerm)
	logFile, err := os.OpenFile("./"+ErrLog+"/" + time.Now().Format("2006-01") + "/" + fmt.Sprintf("%d",time.Now().Day()) +".log", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644)
	if err != nil {
		panic("打开日志文件失败, err:" + err.Error())
	}
	log.SetOutput(logFile)
	log.SetFlags( log.Llongfile | log.Lmicroseconds | log.Ltime)
	log.Println("<New>error：" + Content + "<New>")
}
